import 'package:flutter/material.dart';

class GlobalKeyDemoSub extends StatefulWidget {
  GlobalKeyDemoSub({Key key}) : super(key: key);

  @override
  GlobalKeyDemoSubState createState() => GlobalKeyDemoSubState();
}

class GlobalKeyDemoSubState extends State<GlobalKeyDemoSub> {
  bool isActive = false;
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Switch.adaptive(
        value: isActive,
        onChanged: (bool currentStatus) {
          isActive = currentStatus;
          setState(() {});
        },
      ),
    );
  }

  changeState() {
    isActive = !isActive;
    setState(() {});
  }
}
